# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=scikit-image
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.17.2
pkgrel=1
pkgdesc='Image processing routines for SciPy (mingw-w64)'
arch=('any')
url="http://scikit-image.org/"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-matplotlib" "${MINGW_PACKAGE_PREFIX}-python-scipy" "${MINGW_PACKAGE_PREFIX}-python-pywavelets" "${MINGW_PACKAGE_PREFIX}-python-numpy" "${MINGW_PACKAGE_PREFIX}-python-networkx" "${MINGW_PACKAGE_PREFIX}-python-imageio" "${MINGW_PACKAGE_PREFIX}-python-tifffile" "${MINGW_PACKAGE_PREFIX}-python-pillow")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-cython")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-pyqt5: for imshow(x, fancy=True) and skivi"
"${MINGW_PACKAGE_PREFIX}-freeimage:  for reading various types of image file formats"
"${MINGW_PACKAGE_PREFIX}-python-pyamg: fast cg_mg mode of random walker segmentation")
options=('!emptydirs')
source=("https://files.pythonhosted.org/packages/source/${_realname:0:1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('bd954c0588f0f7e81d9763dc95e06950e68247d540476e06cb77bcbcd8c2d8b3')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build_ext --inplace
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
